import { Module } from 'vuex';

interface UserState {
  isLogin: boolean;
}

const userModule: Module<UserState, any> = {
  namespaced: true,
  state: {
    isLogin: false,
  },
  mutations: {
    setLoginState(state, isLogin: boolean) {
      state.isLogin = isLogin;
    },
  },
  actions: {
    login({ commit }) {
      // 这里可以添加实际的登录逻辑
      commit('setLoginState', true);
    },
    logout({ commit }) {
      commit('setLoginState', false);
    },
  },
  getters: {
    isLoggedIn: (state) => state.isLogin,
  },
};

export default userModule;